<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui">
                
	<h:head><h1>Crea Pacchetto</h1>
	  <style type="text/css">
        .ui-layout-unit{
             border: none;
        }
    </style>
	
					<link type="text/css" href="../generalstyle.css" rel="stylesheet"/>
	
	</h:head>
<body>
	<img src="http://us.123rf.com/400wm/400/400/dirkercken/dirkercken1010/dirkercken101000054/8013039-questo-lato-fino-pacchetto-scatola-di-cartone-con-testo.jpg" alt="" height="200" width="300" />
	<h:form>
        <p:menubar>  
                <p:menuitem value="Home" url="../home.xhtml" />  
				<p:menuitem value="Area Cliente" url="../cliente/homeCliente.xhtml" />
				<p:menuitem value="Area Impiegato" url="../impiegato/homeImpiegato.xhtml" /> 
				<p:menuitem value="Login" url="../login.xhtml" rendered="#{request.remoteUser == null}" />
                <p:menuitem value="Logout" actionListener="#{logoutManagedBean.logout()}" rendered="#{request.remoteUser != null}" />
		</p:menubar>
		</h:form>
		<br></br>
	
	<h:form>
			
			
					<p:layout style=" height:80px;">
			<p:layoutUnit position="west" size="150">
				<p:outputLabel for="cerca" value="Nome Volo" />
			</p:layoutUnit>
			
			<p:layoutUnit position="east">
			<p:commandButton actionListener="#{PacchettoManagedBean.cercaVoli()}" value="CERCA VOLI" ajax="false" />
			<p:commandButton actionListener="#{PacchettoManagedBean.visualizzaVoli()}" value="VISUALIZZA VOLI" ajax="false" />
			</p:layoutUnit>

			<p:layoutUnit position="center">
				<p:inputText id="cerca" value="#{PacchettoManagedBean.cerca}" requiredMessage="Campo obbligatorio" />
			</p:layoutUnit>
		</p:layout>
			
    </h:form>
    
    <ui:repeat value="#{PacchettoManagedBean.voli}" var="voloCorr" varStatus="statoVolo">
        <h:form>
        <p:layout style=" height:100px;">
				<p:layoutUnit position="center">
				
					<p:layout style="height:50px;" >
						<p:layoutUnit position="west" size="200">
							<p:outputLabel value="Volo Partenza: " />
							<p></p>
							<p:outputLabel value="Volo Destinazione: " />
							
						</p:layoutUnit>
						
						<p:layoutUnit position="center">
							<p:outputLabel id="luogoPart" value="#{voloCorr.luogoPartenza}" />
							<p></p>
           					 <p:outputLabel id="luogoDest" value="#{voloCorr.luogoDestinazione}" />
						</p:layoutUnit>
					</p:layout>
					
				</p:layoutUnit>
				<p:layoutUnit position="east" size="600">
						<p:commandButton
						actionListener="#{PacchettoManagedBean.setIdVoloAndata(PacchettoManagedBean.voli.get(statoVolo.index).id)}"
						value="IMPOSTA ANDATA" ajax="false" />
							<p:commandButton
						actionListener="#{PacchettoManagedBean.setIdVoloRitorno(PacchettoManagedBean.voli.get(statoVolo.index).id)}"
						value="IMPOSTA RITORNO" ajax="false" />
				</p:layoutUnit>
			</p:layout>

        
        </h:form>
    </ui:repeat>


	
    
    <h:form>
    <p:panel header="Crea Pacchetto"  style="width:600px; margin:0 auto; text-align:center;">
			<h:panelGrid columns="3" id="regGrid">
	
					<p:outputLabel for="nome" value="Nome"/>
				    <p:inputText id="nome" value="#{PacchettoManagedBean.nome}" requiredMessage="Campo obbligatorio" required="true" />
					<p:message for="nome" />
					
					<p:outputLabel for="numeroPersone" value="Numero Persone" />
					<p:inputText id="numeroPersone" value="#{PacchettoManagedBean.numeroPersone}" requiredMessage="Campo obbligatorio" required="true">
					<f:validateLongRange minimum="1" />
					</p:inputText>
					<p:message for="numeroPersone" />
					
					
			</h:panelGrid>

			<p:commandButton value="CREA PACCHETTO" update="regGrid"
				action="#{PacchettoManagedBean.creaPacchetto()}" />

		</p:panel>
    </h:form>
</body>
</html>